#include <stdio.h>
#include <string.h>

int n, k;
int res[110][3];  // 0 for total , 1 for win, 2 for lose
char s1[100], s2[100];
int tot;
bool first = true;

int main()
{
	int i, j, a, b;

	while (1)
	{
		scanf("%d", &n);
		if (!n) break;
		scanf("%d", &k);
		
		memset(res, 0, sizeof(res));
		for (j=1; j<=k; ++j)
		{
			scanf("%d%s%d%s", &a, s1, &b, s2);
			res[a][0]++;
			res[b][0]++;
			if (s1[0]=='r')
			{
				if (s2[0]=='p') res[a][2]++, res[b][1]++;
				else if (s2[0]=='s') res[a][1]++, res[b][2]++;
			}
			else if (s1[0] == 'p')
			{if (s2[0]=='p') res[a][2]++, res[b][1]++;
				else if (s2[0]=='s') res[a][1]++, res[b][2]++;
				if (s2[0]=='r') res[a][1]++, res[b][2]++;
				else if (s2[0]=='s') res[a][2]++, res[b][1]++;
			}
			else if (s1[0] =='s')
			{
				if (s2[0]=='p') res[a][1]++, res[b][2]++;
				else if (s2[0]=='r') res[a][2]++, res[b][1]++;
			}
		} // end of read one case
		
		if (first) first = false;
		else printf("\n");
		tot = k*(n-1);
		for (i=1; i<=n; ++i)
		{
			if (res[i][0] != tot) printf("-\n");
			else printf("%.3lf\n", res[i][1]*1.0/(res[i][1]+res[i][2]));
		}
		
		
	}	
	
	
	
	return 0;	
}
